package com.atwj.Service.impl;

import com.atwj.Service.UserService;
import com.atwj.dao.UserDao;
import com.atwj.dao.impl.UserDaoImpl;
import com.atwj.entity.User;

/**
 * @author 吴先森
 * @description: UserService实现类
 * @create 2022-03-17 20:47
 */
public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDaoImpl();

    @Override
    public void registUser(User user) {
        userDao.SaveUser(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUsernameAndPassword(user.getUsername(), user.getPassword());
    }

    @Override
    public boolean existsUsername(String username) {
        if (userDao.queryUserByUsername(username) == null) {
            return false;
        } else {
            return true;
        }
    }
}
